package com.lfy.yunpicture.model.enums;

import lombok.Getter;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
@Getter
public enum SpaceRoleEnum {
    VIEWER("观察者","viewer"),
    EDITOR("编辑者","editor"),
    ADMIN("管理员","admin");
    private final String text;
    private final String value;
    SpaceRoleEnum(String text, String value) {
        this.text = text;
        this.value = value;
    }
    public static List<String> getValues() {
        return Arrays.stream(values()).map(SpaceRoleEnum::getValue).collect(Collectors.toList());
    }
    public static SpaceRoleEnum getEnumByValue(String value) {
        if (value == null) {
            return null;
        }
        for (SpaceRoleEnum valueEnum : values()) {
            if (valueEnum.getValue().equals(value)) {
                return valueEnum;
            }
        }
        return null;
    }
}
